import React from "react";
import { createRoot } from "react-dom/client";
const Modal = () => {};

Modal.alert = ({ time = 2000, title = "提示标题" }) => {
  const div = document.createElement("div");
  document.body.appendChild(div);
  const root = createRoot(div);
  const Alert = () => {
    return (
      <div
        style={{
          padding: 10,
          position: "fixed",
          left: "50%",
          top: "50%",
          transform: "translate(-50%, -50%)",
          background: "rgba(0, 0, 0, .6)",
        }}
      >
        <h1 style={{ color: "red" }}>{title}</h1>
      </div>
    );
  };
  root.render(<Alert></Alert>);
  setTimeout(() => {
    div.remove();
  }, 2000);
};

export default Modal;
